package api

import (
	"exam/api/handler"
	"exam/consts"
	"exam/pkg"
	"github.com/gin-gonic/gin"
)

func Router(c *gin.Engine) {
	api := c.Group("/api")
	{
		user := api.Group("/user")
		{
			user.POST("/register", handler.Register)

			user.POST("/login", handler.Login)

		}

		exam := api.Group("/exam")
		{
			exam.POST("/add", handler.AddExam)

			exam.POST("/queryExamById", handler.QueryExamById)

			exam.POST("/update", handler.UpdateExam)

			exam.POST("/delete", handler.DeleteExam)

			exam.POST("/queryExamByCType", handler.QueryExamByCType)

		}
		api.POST("/token", handler.UpdateToken)
		thing := api.Group("/thing")
		{
			thing.Use(pkg.JWTAuth(consts.JWT_KEY))

			thing.POST("/examList", handler.ExamList)

			thing.POST("/examSub", handler.ExamSub)

			thing.POST("/history", handler.History)

		}

	}
}
